import axios from '../axios';

/** *********获取资管产品列表******** */
export const getAssetList = () => axios.post('dz-mall/r/product/getAssetList');

/** *********根据prodCode查询资管产品详情******** */
export const getAssetByCode = (prodCode) => axios.post('dz-mall/r/product/getAssetProd', {
  prodCode
}, {
  loading: true
});

/** *********获取推荐的资管产品******** */
export const getRecommendAsset = (recommStatus = 1) => axios.post('dz-mall/r/product/getRecommendAsset', {
  recommStatus // 非必传
});

/** *********根据资管prodCode查询收益******** */
export const getProdNav = (params) => axios.post('dz-mall/r/product/getProdNav', {
  prodCode: params.prodCode,
  pageNum: params.pageNum,
  pageSize: params.pageSize,
  orderBy: params.orderBy
});

/** *********根据prodCode查询mNum月全部收益******** */
export const getProdAllNav = (params) => axios.post('dz-mall/r/product/getProdAllNav', {
  prodCode: params.prodCode,
  mNum: params.mNum
});

/** *********产品净值收益表现******** */
export const getProdNavPerformance = (prodCode) => axios.post('dz-mall/r/product/getProdNavPerformance', {
  prodCode
});

/** *********资管产品的下订单******** */
export const doAssetOrder = (params) => axios.post('dz-mall/r/order/asset/buy', {
  productCode: params.productCode,
  totPrice: params.totalPrice,
  businessType: params.businessType, // 订单来源，非必须
  orderChannel: params.orderChannel, // 业务类型，非必须
  recommendId: params.recommendId, // 拓展人id，非必须
  managerId: params.managerId// 理财经理id,非必须
}, {
  loading: true
});

/** *********撤销资管产品订单******** */
export const doAssetRevoke = (params) => axios.post('dz-mall/r/order/asset/revoke', {
  allotDate: params.allotDate,
  allotNo: params.allotNo,
  entrustNo: params.entrustNo,
  productCode: params.productCode
});

/** *********资管产品赎回份额******** */
export const assetRedeem = (params) => axios.post('dz-mall/r/order/asset/redeem', {
  productCode: params.productCode,
  amount: params.amount,
  orderChannel: params.orderChannel, // 非必须
  managerId: params.managerId // 非必须
});

/** *********资管产品(天添利)的下订单******** */
export const ttlQuery = (productCode) => axios.post('dz-mall/r/order/ttlQuery', {
  productCode,
});

/** *********资管产品(天添利)的下订单******** */
export const doTTLCancel = (productCode) => axios.post('dz-mall/r/order/asset/ttlCancel', {
  productCode,
});

/** *********修改(天添利)登记金额或暂停******** */
export const doTTLModify = (params) => axios.post('dz-mall/r/order/asset/ttlModify', {
  productCode: params.productCode,
  money: params.money, // 登记金额，非必须
  status: params.status, // 1：暂停，0：正常，非必须
  orderChannel: params.orderChannel // 订单来源
});

/** *********获取资管小集合产品预约赎回委托订单******** */
export const getAssetPreRedeemOrders = () => axios.post('dz-mall/r/order/asset/getPreRedeemEntrust');

/** *********获取资管小集合产品预约赎回历史委托订单******** */
export const getAssetPreRedeemHisOrders = (dayNum) => axios.post('dz-mall/r/order/asset/getPreRedeemEntrustHis', {
  dayNum
});

/** *********资管小集合产品预约赎回******** */
export const assetPreRedeem = (params) => axios.post('dz-mall/r/order/asset/preRedeem', {
  productCode: params.productCode,
  amount: params.amount,
  hopeDate: params.redeemDate,
  orderChannel: params.orderChannel
});

/** *********资管小集合产品预约赎回委托撤销******** */
export const revokeAssetPreRedeem = (allotNo) => axios.post('dz-mall/r/order/asset/revokePreRedeemEntrust', {
  allotNo
});

/** *********旗峰1号持仓明细******** */
export const getAssetPosDetail = () => axios.post('dz-mall/r/order/getAssetPositionDetail');
